/*~-1*/
/*~XSF_LANGUAGE: C/C++*/
/*~A:1*/
/*~+:File Header*/
/*~T*/
/****************************************************************************
 * 
 ****************************************************************************/

/*~E:A1*/
/*~A:2*/
/*~+:Import*/
/*~T*/
/* Import                                                                      */

/*~T*/
/* generic definitions */
#include <general.h>

/*~T*/
#define _SFR_ASM_COMPAT 1
#include <avr/io.h>
#undef _SFR_ASM_COMPAT

/*~T*/
/* own header file */
#include <line.h>

/*~T*/

/*~E:A2*/
/*~A:3*/
/*~+:Private Type Definitions            */
/*~T*/
/* Private Types Definitions                                                   */

/*~T*/
typedef struct{
                u16 port;         /* port to which the line is connected */
                u8 line;          /* line number */
                u8 line_val;       /* line value for input on (0 or 1) */
              }LINE_CNF_TYPE;

/*~E:A3*/
/*~A:4*/
/*~+:Configuration          */
/*~T*/
/* number of input lines configured, max 8 */
#define LINE_MAX_NR  3
/*~T*/
/* input lines configuration : */
/* { port, line, value for line on }  */
static const LINE_CNF_TYPE line_cnf[LINE_MAX_NR]={
    {PINB, PB0, 1},
    {PINC, PC4, 1},
    {PINC, PC5, 1}
    };
/*~E:A4*/
/*~A:5*/
/*~+:Public Functions*/
/*~T*/
/* Public Functions                                                            */

/*~A:6*/
/*~+:void line_init(void)*/
/*~F:7*/
void line_init(void)

/*~-1*/
{
   /*~T*/

/*~-1*/
}
/*~E:F7*/
/*~E:A6*/
/*~A:8*/
/*~+:u8 line_status(u8 line_nr)*/
/*~F:9*/
u8 line_status(u8 line_nr)
/*~-1*/
{
   /*~A:10*/
   /*~+:local variables*/
   /*~T*/
   u8 tmp_u8;

   /*~E:A10*/
   /*~T*/
   /* read the line value */
   tmp_u8 = (_SFR_BYTE(line_cnf[line_nr].port) >> line_cnf[line_nr].line) & 0x01;

   /*~I:11*/
   if (line_cnf[line_nr].line_val)
   /*~-1*/
   {
      /*~T*/
      /* line has 1 as active value */

      /*~T*/
      return tmp_u8;

   /*~-1*/
   }
   /*~O:I11*/
   /*~-2*/
   else
   {
      /*~T*/
      /* line has 0 as active value */

      /*~T*/
      return ((~tmp_u8) & 0x01);

   /*~-1*/
   }
   /*~E:I11*/
   /*~T*/

/*~-1*/
}
/*~E:F9*/
/*~E:A8*/
/*~T*/

/*~E:A5*/
/*~T*/

